﻿using System;
using System.IO;

namespace ScriptXCompiler
{
    class FileOutput : IOutput
    {
        private StreamWriter _w;
        public FileOutput(string path, bool append)
        {            
            _w = new StreamWriter(path, append);
        }

        public void WriteWithIdent(int number, string str)
        {
            string s = new string(' ', number);
            _w.Write(s + str);
        }

        public void WriteWithIdent(int number, string fmt, params object[] args)
        {
            string s = new string(' ', number);
            _w.Write(s + string.Format(fmt, args));
        }

        public void WriteLineWithIdent(int number, string str)
        {
            string s = new string(' ', number);
            _w.WriteLine(s + str);
        }

        public void WriteLineWithIdent(int number, string fmt, params object[] args)
        {
            string s = new string(' ', number);
            _w.WriteLine(s + string.Format(fmt, args));
        }

        public void Write(string str)
        {
            _w.Write(str);
        }

        public void Write(string fmt, params object[] args)
        {
            _w.Write(string.Format(fmt, args));
        }

        public void WriteLine(string str)
        {
            _w.WriteLine(str);
        }

        public void WriteLine(string fmt, params object[] args)
        {
            _w.WriteLine(string.Format(fmt, args));
        }

        public void Dispose()
        {
            _w.Flush();
            _w.Dispose();
        }
    }
}
